<style>
    .top_time{display:none;}
</style>
<div class="nav-tabs-custom">
    <ul class="nav nav-tabs">
        <li class=""><a href="{:Url('index')}">列表</a></li>
        <li class="active"><a href="#">编辑文章</a></li>
    </ul>
    
    <form class="form-horizontal js-ajax-form" method="post" action="{:Url('edit_post')}">
        <div class="box-body mt10">
            <div class="form-group">
                <label class="col-sm-2 control-label">所属栏目</label>
                <div class="col-sm-9">
                    <select name="column_id" class="form-control select2">
                        <option value="">请选择</option>
                        {volist name="columns" id="vo"}
                        <option value="{$vo.id}" {if condition="$column_id eq $vo['id']"}selected{/if}>{$vo._name|raw}</option>
                        {/volist}
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">标题 <span>*</span></label>
                <div class="col-sm-9">
                    <input type="text" name="title" class="form-control" placeholder="标题" value="{$title}" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">副标题</label>
                <div class="col-sm-9">
                    <input type="text" name="subtitle" class="form-control" placeholder="副标题" value="{$subtitle}" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">关键词 <span>*</span></label>
                <div class="col-sm-9">
                    <input type="text" name="keywords" class="form-control" placeholder="关键词" value="{$keywords}" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">缩略图</label>
                <div class="col-sm-2">
                    <a href="javascript:;" class="upload_thumb" onclick="flashupload('图片上传','thumb', thumb_images, '1,baseImage'); return false;">
                        {if (!empty($thumb))}
                        <img src="{$thumb}" id="thumb_preview" style="max-width:100px; max-height:100px;" />
                        <input type="hidden" name="thumb" id="thumb" value="{$thumb}" />
                        {else /}
                        <img src="__IMG__/icon/default-thumbnail.png" id="thumb_preview" style="max-width:100px; max-height:100px;" />
                        <input type="hidden" name="thumb" id="thumb" />
                        {/if}
                    </a>
                    <div class="mt5">
                        <button class="btn btn-xs btn-danger" onclick="$('#thumb_preview').attr('src','__IMG__/icon/default-thumbnail.png');$('#thumb').val('');return false;">取消图片</button>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">内容描述 <span>*</span></label>
                <div class="col-sm-9">
                    <textarea name="description" rows="3" class="form-control" placeholder="内容描述">{$description}</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">文章内容 <span>*</span></label>
                <div class="col-sm-9">
                    {if condition="$editor_type eq 1"}
                    <script id="editor" name="content" type="text/plain" style="height:300px;">{$content|raw}</script>
                    {else /}
                    <div id="md_editor">
                        <textarea style="display:none;" name="content">{$content}</textarea>
                    </div>
                    {/if}
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">信息来源</label>
                <div class="col-sm-5">
                    <input type="text" name="source" class="form-control" placeholder="信息来源" value="{$source}" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">作者</label>
                <div class="col-sm-2">
                    <input type="text" name="author" class="form-control" placeholder="作者" value="{$author}" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">阅读量</label>
                <div class="col-sm-2">
                    <input type="number" name="read_number" min="0" class="form-control" placeholder="阅读量" value="{$read_number}" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">文章置顶</label>
                <div class="col-sm-2">
                    <select name="is_top" class="form-control select2 is_top">
                        <option value='0' {if condition="$is_top eq 0"}selected{/if}>否</option>
                        <option value='1' {if condition="$is_top eq 1"}selected{/if}>永久置顶</option>
                        <option value='2' {if condition="$is_top eq 2"}selected{/if}>时间段置顶</option>
                    </select>
                </div>
            </div>
            <div class="form-group top_time" {if condition="$is_top eq 2"}style="display:block;"{/if}>
                <label class="col-sm-2 control-label">置顶时间段</label>
                <div class="col-sm-6">
                    <input type="text" name="top_start_time" id="start_time" class="form-control laydate-icon-move display_de width160" value="<?php echo date('Y-m-d H:i:s',time());?>" /> - 
                    <input type="text" name="top_end_time" id="end_time" class="form-control laydate-icon-move display_de width160" value="<?php echo date('Y-m-d H:i:s',strtotime('+30 day'));?>" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">推荐位</label>
                <div class="col-sm-2">
                    {volist name="pos_list" id="vo"}
                    <label style="font-weight:100">
                        <input type="checkbox" class="minimal" name="position_ids[]" value="{$key}" {if condition="in_array($key, $position_ids)"}checked{/if} /> {$vo}
                    </label>
                    {/volist}
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">Tag标签</label>
                <div class="col-sm-9">
                    <input type="text" class="form-control newsTag" name="tags" value="<?php echo !empty($tags) ? $tags : ''; ?>" />
                    <span>Tag标签，最多10个Tag标签且每个Tag标签不能超过10个字</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">原创</label>
                <div class="col-sm-2">
                    <select name="is_original" class="form-control select2">
                        {volist name="is_originals" id="vo"}
                        <option value='{$key}' <?php echo ($key == $is_original) ? 'selected' : '';?>>{$vo}</option>
                        {/volist}
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">状态</label>
                <div class="col-sm-2">
                    <select name="status" class="form-control select2">
                        <option value='1' {if condition="$status eq 1"}selected{/if}>发表</option>
                        <option value='0' {if condition="$status eq 0"}selected{/if}>草稿箱</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">添加时间</label>
                <div class="col-sm-2">
                    <input type="text" name="create_time" class="form-control laydate-icon-move" id="laydate_time" value="{$create_time}" />
                </div>
            </div>
        </div>
        <div class="box-footer">
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <input type="hidden" name="id" value="{$id}" />
                    <button type="button" class="btn btn-primary js-ajax-submit">保存</button>
                    <a href="javascript:" onclick="self.location=document.referrer;" class="btn btn-default">返回</a>
                </div>
            </div>
        </div>
    </form>

</div>

<link rel="stylesheet" href="__JS__/iCheck/all.css">
<script src="__JS__/iCheck/icheck.min.js"></script>
<link rel="stylesheet" href="__JS__/tagsinput/tagsinput.css">
<script src="__JS__/tagsinput/tagsinput.min.js"></script>
<!--区分普通富文本编辑和Markdown编辑器-->
{if condition="$editor_type eq 1"}
<script type="text/javascript" charset="utf-8" src="__JS__/ueditor/ueditor.config.js?v=1.0"></script>
<script type="text/javascript" charset="utf-8" src="__JS__/ueditor/ueditor.all.min.js"> </script>
<script type="text/javascript">
var ue = UE.getEditor('editor',{
    autoFloatEnabled: false,
});
</script>
{else /}
<link rel="stylesheet" href="__JS__/editormd/css/editormd.css" />
<script src="__JS__/editormd/editormd.min.js"></script>
<script src="__JS__/editormd/editormd.com.js"></script>
{/if}

<script type="text/javascript">
$(function(){
    $('.is_top').change(function(){
        var top = $(this).val();
        if (top == 2) {
            $('.top_time').show();
        } else {
            $('.top_time').hide();
        }
    });
    $('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
        checkboxClass: 'icheckbox_minimal-blue',
        radioClass: 'iradio_minimal-blue'
    });
    $(".newsTag").tagsinput({maxTags:10, maxChars:20});
});
var ids = new Array('thumb', 'banner');
</script>
{include file="public:thumb_many" /}